<template>
  <div id="app">
    <div class="info">
      <div class="title">{{ news.title }}</div>
      <div class="info">
        <div class="time">{{ formatTime(news.updatedAt) }}</div>
      </div>
      <div class="summary">{{ news.summary }}</div>
    </div>
    <div class="media">
      <h2>媒体报道</h2>
      <ol class="source">
        <li v-for="item in news.newsArray" :key="item.id" class="source-item">
          <div>{{item.title}}</div>
        </li>
      </ol>
    </div>
  </div>
</template>

<script>
import JSBridge from '../../../common/jsbridge'
import dayjs from 'dayjs'
import news from '../news.json'

export default {
  name: 'App',
  components: {
  },
  data() {
    return {
      news: {},
    }
  },
  created() {
    JSBridge.Navigation.getParams((params) => {
      this.news = news.data.find(item => item.id === params.id)
    })
  },
  methods: {
    formatTime(time) {
      return dayjs(time).format('MM月DD日 HH:mm')
    }
  }
}
</script>

<style>
body {
  padding: 0;
  margin: 0;
}

#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  background: #eee;
  padding-bottom: 20px;
}

.info {
  padding: 18px;
  background-color: white;
}

.info .title {
  font-weight: bold;
  font-size: 20px;
  text-align: left;
  color: #2c3e50;
}

.info .summary {
  margin-top: 5px;
  color: #444;
  font-size: 18px;
  text-align: left;
}

.info .time {
  text-align: left;
  font-size: 14px;
  color: #aaa;
}

.media {
  margin-top: 16px;
  padding: 18px;
  background-color: white;
}

.media h2 {
  font-size: 20px;
  text-align: left;
  padding: 0;
  margin: 0;
}

.source {
  padding-left: 20px;
}

.source .source-item {
  text-align: left;
  margin-bottom: 10px;
  list-style-type: disc;
}

</style>
